package com.dingding.order.core.publish.sql;

/**
 * @ClassName: RegularRoutePushSql 
 * @Description: 顺路推送
 * @author YHQ
 * @date 2016年6月4日 下午2:24:31
 */
public class RegularRoutePushSql {

	/**
	 * 用户下单-获取要推送的目标用户信息
	 */
	public static final String GET_PUSH_USER_INFO(Integer userType) {

		StringBuilder sBuilder = new StringBuilder();

		sBuilder.append("SELECT ur.setOutTime,ur.startLongitude,ur.startLatitude,ur.purposeLongitude,ur.purposeLatitude,ul.aliasId,ul.loginEquipment,ups.orderReminder, ups.weekendPush,ups.regularRouteConditions, ud.currentCity FROM userpushsetting ups INNER JOIN userroute ur ON ups.loginId = ur.loginId INNER JOIN userlogin ul ON ups.loginId = ul.uid INNER JOIN userdetail ud ON ul.uid = ud.loginId WHERE (ups.orderReminder = 1 OR ups.weekendPush = 1) AND ur.isEnable = 1 AND ul.userStatus = 1");

		if (userType == 1) {	//司机下单
			sBuilder.append(" AND ul.userRole in (1,2)");
		} else if (userType == 2) { //乘客下单
			sBuilder.append(" AND ul.userRole in (1)");
		}

		sBuilder.append(" AND ups.loginId != ?");

		return sBuilder.toString();
	}
	
}
